package com.schoolai.schoolworkflow.task.listeningtraining;

import com.schoolai.feign.ai.IFeignAIController;
import com.schoolai.util.base.Result;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;
import org.flowable.task.service.delegate.DelegateTask;
import org.flowable.task.service.delegate.TaskListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Copyright(C),2019-2025，XX公司
 * FileName:CreateArticle
 * Author:bobby
 * 创建时间：2025/9/28 10:41
 * Description:听力训练创建文章
 * History:
 * <auth>        <time>       <version>       <desc>
 * 作者          修改时间       版本号         描述
 */
@Slf4j
@Component("CreateArticle")
public class CreateArticle implements JavaDelegate {
    @Autowired
    IFeignAIController IFeignAIController;
    @Override
    public void execute(DelegateExecution execution) {
        // 用于排他网关判断的变量。设置在工作量模型的箭头上面
        Result result =IFeignAIController.createArticleByNewWorks("1");
        String EnglishArticle = result.getData().toString();
        execution.setVariable("isCreateArtile", true);
        execution.setVariable("EnglishArticle", EnglishArticle);
        log.info("AI生成文章:" + EnglishArticle);
    }
}
